#include "mpx_supt.c"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void date(char opt[6], char dte[20]);

int main(int argc, char *argv[]){
   char par1[6]="set";
   char par2[20]="09-18-2008";
   char par3[6]="get";

   date(par1, par2);
   date(par3, par2);
   system("pause");
   return 0;
}

void date(char opt[6], char dte[20]){
   char *p;
   int i=0, temp;
   date_rec aDate;

   switch (opt[0]){
      case 's':
      p=strtok(dte,"-");
      while(p!=NULL){
	temp=atoi(p);
	if(i==0){
	  aDate.month=temp;
	}
	if(i==1){
	  aDate.day=temp;
	}
	if(i==2){
	  aDate.year=temp;
	}
	i++;
	p=strtok(NULL, "-");
      }

      sys_set_date(&aDate);
      printf("Date successfully set! \n");

      break;

      case 'g':
      sys_get_date(&aDate);

      switch (aDate.month){
	 case 1:
	   printf("January %d, %u \n", aDate.day, aDate.year);
	   break;
	 case 2:
	   printf("February %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 3:
	   printf("March %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 4:
	   printf("April %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 5:
	   printf("May %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 6:
	   printf("June %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 7:
	   printf("July %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 8:
	   printf("August %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 9:
	   printf("September %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 10:
	   printf("October %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 11:
	   printf("November %d, %d \n", aDate.day, aDate.year);
	   break;
	 case 12:
	   printf("December %d, %d \n", aDate.day, aDate.year);
	   break;
	 case NULL:
	   printf("Date has not yet been set.  Please set today's date.\n");
	   break;
	 default:
	   printf("Not an actual month?\n");
	   break;
	}
      break;

      default:
	 printf("Not a recognized command \n");
	 break;
      }
}